package com.xzw.cameratest.common;

import com.android.business.entity.EnvironmentInfo;
import com.android.business.entity.UserInfo;
import com.xzw.cameratest.utils.SPUtils;


/**
 * 作者：ZXD
 * 日期：2020/4/27
 * 描述：单例类（保存数据）
 **/
public class CommonInfo {

    private UserInfo mUserInfo;
    private EnvironmentInfo mEnvironmentInfo;

    static class Instance {
        static CommonInfo instance = new CommonInfo();
    }

    public static CommonInfo getInstance() {
        return Instance.instance;
    }

    public void setUserInfo(UserInfo userInfo) {

        this.mUserInfo = userInfo;
    }

    public UserInfo getUserInfo() {
        return mUserInfo;
    }

    public void setEnvironmentInfo(EnvironmentInfo environmentInfo) {
        this.mEnvironmentInfo = environmentInfo;
    }

    public EnvironmentInfo getEnvironmentInfo() {
        return mEnvironmentInfo;
    }

    /**
     * 保存ip和端口号以及登录成功的用户名和密码
     */
    public void saveLoginData(String ip, String port, String username, String password){
//        String restToken = (String)mUserInfo.getExtandAttributeValue("token");
//        mEnvironmentInfo.setRestToken(restToken);
        SPUtils.saveString(Config.IP, ip);
        SPUtils.saveString(Config.PORT, port);
        SPUtils.saveString(Config.USERNAME, username);
        SPUtils.saveString(Config.PASSWORD, password);
    }
}
